package PRSystem_Main;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class PRSystem_connection {

	// 접속 만 가능
	public Connection makeConn() throws Exception {

		  String DRV = "oracle.jdbc.driver.OracleDriver";
		  String URL = "jdbc:oracle:thin:@112.216.253.124:1521:xe";
		  String USR = "godraines";   // jhlee183, godraines
		  String PWD = "godraines";

		Connection conn = null;
		Class.forName(DRV);
		conn = DriverManager.getConnection(URL, USR, PWD);
		return conn;
	}

	// sql = ADSF 문~
	// 입력값... 조회 대상 vo 받아 오기
	// pstmt = conn.prepareStatement(selectSQL);

	// 접속 끊기
	public void closeConn(Connection conn, PreparedStatement pstmt, ResultSet rs) {

		if (rs != null)
			try {
				rs.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		if (pstmt != null)
			try {
				pstmt.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		if (conn != null)
			try {
				conn.close();
			} catch (Exception e) {
				e.printStackTrace();
			}

	}

	public void closeConn(Connection conn, PreparedStatement pstmt) {
		if (pstmt != null)
			try {
				pstmt.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		if (conn != null)
			try {
				conn.close();
			} catch (Exception e) {
				e.printStackTrace();
			}

	}

}
